package com.emergency.assist.dao;

import com.emergency.assist.domain.OrderAssign;
import com.emergency.assist.domain.Resource;
import com.emergency.assist.domain.RoutePoint;
import com.emergency.assist.domain.RouteRelation;
import com.emergency.base.domain.Order;
import com.emergency.base.domain.Plan;
import com.emergency.base.domain.PlanDetail;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/*
*
 * Created by qiuyan.pei on 2020/3/12.
*/


public interface DistributeDao extends JpaRepository<Resource, String>, JpaSpecificationExecutor<Resource> {

    @Query(value = "select * from bus_resource where grade=?1 and environment=?2 and if(?3>0,army=?3,1=1)",nativeQuery = true)
    List<Resource> findByParam(int grade,int environment,int army);

    @Query("select rp from PlanDetail rp where plan.id=:planId")
    List<PlanDetail>findByPlan(@Param("planId") long planId);

    @Query("select rp from Plan rp where scenar.id=:scenarId")
    Plan findByScenar(@Param("scenarId") long scenarId);


    @Query("select rp from Order rp where id=:orderId")
    Order findByOder(@Param("orderId") long orderId);


}
